tools/hotplug: support vif-post.d hook arrangements
authorW. Michael Petullo <mike@flyn.org>
Wed, 25 May 2011 09:45:24 +0000 (10:45 +0100)
committerW. Michael Petullo <mike@flyn.org>
Wed, 25 May 2011 09:45:24 +0000 (10:45 +0100)
New feature: you can drop hook scripts into
 /etc/xen/scripts/vif-post.d/*.hook

Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/hotplug/Linux/vif-bridge
tools/hotplug/Linux/vif-nat
tools/hotplug/Linux/vif-post.d/00-vif-local.hook [new file with mode: 0644]
tools/hotplug/Linux/vif-route
tools/hotplug/Linux/xen-hotplug-common.sh

index 14988053790cd7f5e74b8fc0bd6b9e2d81dc7b8e..f48951935af431dc581be3813f5139ed2341f78b 100644 (file)
@@ -105,6 +105,8 @@ if [ "$type_if" = vif ]; then
     handle_iptable
 fi
 
+call_hooks vif post
+
 log debug "Successful vif-bridge $command for $dev, bridge $bridge."
 if [ "$type_if" = vif -a "$command" = "online" ]
 then
index 9082cc96bbb29c5a5cd164eb410d6f9958df4de3..8d29fb6ea27f186d4df66db88dd184f8ffd2d7a3 100644 (file)
@@ -185,6 +185,8 @@ esac
 
 handle_iptable
 
+call_hooks vif post
+
 log debug "Successful vif-nat $command for ${dev}."
 if [ "$command" = "online" ]
 then
diff --git a/tools/hotplug/Linux/vif-post.d/00-vif-local.hook b/tools/hotplug/Linux/vif-post.d/00-vif-local.hook
new file mode 100644 (file)
index 0000000..d7d4453
--- /dev/null
@@ -0,0 +1,18 @@
+#============================================================================
+# ${XEN_SCRIPT_DIR}/vif-post.d/00-vif-local.hook
+#
+# Script for performing local configuration of a vif.
+# This script will be sourced by, e.g., vif-bridge after the hotplugging
+# system calls vif-bridge. The script is here and not simply executed as
+# a udev rule because this allows simple access to several environment
+# variables set by the calling vif-* script.
+#
+# Environment vars:
+# command     (add|remove|online|offline)
+# dev         vif interface name (required).
+# main_ip     IP address of Dom0
+# ip          list of IP networks for the vif, space-separated
+# XENBUS_PATH path to this device's details in the XenStore (required).
+#============================================================================
+
+# Place local modifications here.
index 6c5587afd5ccdddeaed20f8d1094f485e3d9ac4e..02f1403a54941f6923febc2f74a83f2d3f71f61c 100644 (file)
@@ -49,6 +49,8 @@ fi
 
 handle_iptable
 
+call_hooks vif post
+
 log debug "Successful vif-route ${command} for ${dev}."
 if [ "${command}" = "online" ]
 then
index 370f9ade2f77874c1135a2c9771cfff1876db305..95beab0ec56be516aa0b219d7421beac8fd1aba5 100644 (file)
@@ -99,4 +99,15 @@ xenstore_write() {
   _xenstore_write "$@" || fatal "Writing $@ to xenstore failed."
 }
 
+##
+# call_hooks <devtype> <hook>
+#
+# Execute each hook in the <hook> directory.
+#
+call_hooks() {
+  for f in /etc/xen/scripts/${1}-${2}.d/*.hook; do
+    [ -x "$f" ] && . "$f"
+  done
+}
+
 log debug "$@" "XENBUS_PATH=$XENBUS_PATH"